#ifndef PLAYERMANAGER_H
#define PLAYERMANAGER_H

#include "../../Frame/Player.h"
#include "../../Frame/Debug.h"

#include <list>
#include <map>

using namespace std;

class PlayerManager
{
	public:
		PlayerManager();
		~PlayerManager();

		Player* GetPlayer(int _PlayerId);
		Player* GetPlayerByFd(int _fd);
		int GetPlayerIdByUserId(int _userId, int _fd);

		// 根据userId 返回socket_fd;
		int GetUserFd(int _userId);

		// 根据_fd 获取UserId;
		int GetUserId(int _fd);

		// 更新玩家数据
		bool UpdatePlayer(const Player& _Player);

		bool UpdateFDID(int _fd, int _PlayerId);

	protected:
	private:


		map<int, int> m_fdIDMap; 					// <fd, playerId>映射登录和离线的时候 需要维护

		map<int, Player> m_PlayerMap; 				// <playerId, Player>

		map<int, int> m_UserIdPlayerIdMap;			// 用户Id 到 玩家Id 的映射

		map<int, int> m_userIdFdMap; 				// <userId, fd> 映射

};

#endif // PLAYERMANAGER_H
